import 'package:flutter/material.dart';
import 'package:flutter_module/page/emergency_page.dart';
import 'package:flutter_module/page/system_page.dart';
import 'package:flutter_module/page/uzi_page.dart';
import 'package:flutter_screenutil/screenutil.dart';

import 'cars_page.dart';
import 'home_page.dart';
class Tap extends StatefulWidget {
  @override
  _TapState createState() => _TapState();
}

class _TapState extends State<Tap> {
  final List<Widget> item=[
  new HomePage(),EmergencyPage(),CarPage(),UziPage(),SystemPage()
  ];
  int index=0;
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334);
    return Scaffold(
    body: IndexedStack(
      index: index,
      children: item,
    ),
    bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: index,
        onTap: (index){
          setState(() {
            this.index=index;
          });
        },
        items: getItems(),
    ),
    );
  }

  List<BottomNavigationBarItem> getItems(){
    List<BottomNavigationBarItem> items=[];
    items.add(BottomNavigationBarItem(icon: Icon(Icons.home),title: Text("首页")));
    items.add(BottomNavigationBarItem(icon: Icon(Icons.person_add),title: Text("抢险")));
    items.add(BottomNavigationBarItem(icon: Icon(Icons.airport_shuttle),title: Text("车辆")));
    items.add(BottomNavigationBarItem(icon: Icon(Icons.view_headline),title: Text("物资")));
    items.add(BottomNavigationBarItem(icon: Icon(Icons.person),title: Text("系统")));
    return items;
  }
}
